// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose: declaration of internet assistance functions.
//   $Id$

#ifndef ___FP__INET_FUNCTIONS_H___
#define ___FP__INET_FUNCTIONS_H___
#include "wininet.h"

HRESULT fetchHTTPDocument(BSTR sURL,BSTR * psText);
BSTR Relative2AbsolutePath(BSTR sFromDoc, BSTR sRelPath, bool bURLEncode=false);
HRESULT fetchHTTPDocument(BSTR sURLCurrent,BSTR sURLRel,BSTR * psText);
CString URLEncode(CString sIn);
HRESULT fetchHTTPBinaryDocument(BSTR sURL, void **ppBuf, DWORD &dwBufSize);
//<summary>name to identify our internet application to servers</summary>
const char * const bsInternetAppName = "X-Port XLink Engine";
//<summary>
//	opens an internet handle (uses ::InternetOpen/5)
//	with our default parameters.
//</summary>
//<returns>The handle, which must be closed using InternetCloseHandle  </returns>
inline HINTERNET OpenInternetHandle()
{
	return ::InternetOpen(
			bsInternetAppName,
			INTERNET_OPEN_TYPE_PRECONFIG,
			NULL,
			NULL,
			NULL
		);
};

//<summary>
//	opens a handle to a URL.
//</summary>
//<param name="pdwReturnCode">
//	[out] pointer to a DWORD to receive the return code from
//	opening the URL (200=OK, 404=not found etc.)
//</param>
HINTERNET getURLHandle(HINTERNET HINet, BSTR sURL,DWORD * pdwReturnCode);

#endif
